package com.yesep.learn.jwt.demo.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yesep.learn.jwt.common.R;
import com.yesep.learn.jwt.demo.model.User;
import com.yesep.learn.jwt.demo.service.UserService;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@RestController
public class AuthController {
	@Autowired
	private UserService srv;

	/**
	 * 未登录提示
	 */
	@GetMapping("/")
	public R<Object> index() {
		R<Object> vo = R.me(403, "令牌缺失");
		return vo;
	}

	@GetMapping("/list")
	public R<Object> list() {
		List<User> list = new ArrayList<>();
		list.add(srv.get("admin"));
		R<Object> r = R.success();
		r.setPayload(list);
		return r;
	}

	/**
	 * 用户登录 
	 */
	@GetMapping("/login")
	public void login() {
	}

	/**
	 * 用户退出
	 */
	@GetMapping("/logout")
	public void logout() {
	}
}
